package com.ftg.learn.chapter10.work01;

import java.util.function.BiPredicate;
import java.util.function.Predicate;

/**
 * 练习
 * 1 : 接口
 * 1.1 : 一个抽象方法 有几个参数 有没有返回值 x->{} (x,y) ()
 * 2 : 处理类
 * 2.1 也有方法 调用函数式接口
 * <p>
 * 1 : 我有一个学生类 (student) 里面有如下状态 sno,sname,age
 * 2 : 完成的功能可以根据学生信息进行比较
 * 2.1 : 给你两个学生信息，你帮我谁的条件(sno,sname ,age)大  boolean bijiao(学生 x，学生 y)
 * <p>
 * <p>
 * 3.如果添加一个处理类，可以如何来写
 * <p>
 * 集合
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/2/1 上午8:09
 */
public class Question {

    public static void main(String[] args) {
        MyCompare<Student> compare = (x, y) -> x.getAge() - y.getAge() > 0;
        MyCompare<Student> compare1 = (x, y) -> x.getSno() - y.getSno() > 0;

        MyCompare<Student> compare2 = (x, y) -> {
            String xName = x.getSname();
            String yName = y.getSname();

            System.out.println(xName.codePointAt(0));
            System.out.println(yName.codePointAt(0));

            return xName.codePointAt(0) - yName.codePointAt(0) > 0;

        };

        MyCompare<Student> compare3 = (x, y) -> x.getSname().compareTo(y.getSname()) > 0;

        Student stu1 = new Student();
        stu1.setSno(1);
        stu1.setSname("张三");
        stu1.setAge(29);

        Student stu2 = new Student();
        stu2.setSno(2);
        stu2.setSname("李四");
        stu2.setAge(26);

        System.out.println(compare.bijiao(stu1, stu2));
        System.out.println(compare1.bijiao(stu1, stu2));

        System.out.println(compare3.bijiao(stu1, stu2));

        // 猫  狗   狼

        Predicate<Student> predicate1 = x -> x.getAge() > 10;
        BiPredicate<Student, Student> predicate2 = (x, y) -> x.getAge() - y.getAge() > 0;

    }

}
